package LuoGu.暴力.回文质数;

import java.util.Arrays;

public class Temp {
    public static void main(String[] args) {
        int ans = 0;
        int [] temp = new int [1000000001];
        Arrays.fill(temp,1);
        for(int i=2;i<=1000000000;i++){
            if(temp[i]==1){
                for(int j=i*2;j<=1000000000;j+=i){
                    temp[j] = 0;
                }
            }
        }
        for(int i=1000000000;i>=2;i--){
            if(temp[i]==1){
                StringBuffer temp1 = new StringBuffer(String.valueOf(i));
                if(!temp1.reverse().toString().equals(String.valueOf(i))) temp[i] = 0;
            }
        }
        for(int i=2;i<1000000001;i++){
            if(temp[i]==1){
                ans++;
                System.out.print(i+",");
            }
        }
        System.out.println();
        System.out.print(ans);
    }
}
